
package pw.jeb;


/**
 * Enforces a thread confinement policy for methods on a particular event bus.
 *
 * @author Jake Wharton
 */
public interface ThreadEnforcer {

  /**
   * 执行所在的线程
   * @param runnable
   */
  void run(Runnable runnable);


  /** A {@link ThreadEnforcer} that does no verification. */
  ThreadEnforcer ANY = new ThreadEnforcer() {

    public void run(Runnable runnable){
      runnable.run();
    }
  };

  /** A {@link ThreadEnforcer} that confines {@link Jeb} methods to the main thread. */
//  ThreadEnforcer ANDROID = new ThreadEnforcer() {
//    @Override public void enforce(Jeb bus) {
//      if (Looper.myLooper() != Looper.getMainLooper()) {
//        throw new IllegalStateException("Event bus " + bus + " accessed from non-main thread " + Looper.myLooper());
//      }
//    }
//  };

}
